package service;

import java.sql.*;
import dao.CustomerDao;
import model.Customer;
import util.DataBaseConnection;

public class CustomerService implements CustomerDao {
	//添加客户信息
	public void addCoustomer(Customer cus) {
		String sql = "insert into customer_info (name, address, occupation) values ('"+ cus.getName() + "','" + cus.getAddress() + "','" + cus.getOccupation() +"')";
		DataBaseConnection.updateDataBase(sql);
	}
	
	//添加用户办卡类型
	public void insertCardType(Customer cus) {
		String sql = "update customer_info set card_type = " + cus.getCardType() + " where name = '" + cus.getName() + "'";
		DataBaseConnection.updateDataBase(sql);
	}
	
	//获得客户卡号
	public int getCardId(Customer cus) {
		String sql = "select card_id from customer_info where name = '" + cus.getName() + "'";
		String result[] = DataBaseConnection.queryDataBase(sql, 1).split(" ");
		return Integer.valueOf(result[0]);
	}



}
